package Practice05.test3;

public class CheckingAccount extends Account{

    private double overdraftProtection;//透支额度

    public CheckingAccount(double bal) {
        super(bal);
    }

    public CheckingAccount(double bal, double overdraftProtection) {
        super(bal);
        this.overdraftProtection = overdraftProtection;
    }

    @Override
    public boolean withdraw(double amount) {
        if (amount <= balance){
            balance -= amount;
            return true;
        }else if (amount > balance+overdraftProtection){
            return false;
        }else {
            balance = 0;
            overdraftProtection -= amount-balance;
            return true;
        }
    }
}
